package com.ruoyi.system.controller;

import java.util.Date;
import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ViewEquipmentData;
import com.ruoyi.system.service.IViewEquipmentDataService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author zbm
 * @date 2023-06-29
 */
@Api("设备数据")
@RestController
@RequestMapping("/system/data")
public class ViewEquipmentDataController extends BaseController
{
    @Autowired
    private IViewEquipmentDataService viewEquipmentDataService;

    /**
     * 查询VIEW列表
     */
    @ApiOperation("查询设备数据列表")
    @PreAuthorize("@ss.hasPermi('system:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(String equipmentName,
                              String equipmentType,
                              String createTime,
                              String dataType,
                              String dataValue,
                              Date startTime,
                              Date endTime) {
        startPage();
        List<ViewEquipmentData> list = viewEquipmentDataService.selectViewEquipmentDataList(equipmentName,equipmentType,createTime,dataType,dataValue,startTime,endTime);
        return getDataTable(list);
    }
    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:data:query')")
    @GetMapping(value = "/{equipmentName}")
    public AjaxResult getInfo(@PathVariable("equipmentName") String equipmentName)
    {
        return success(viewEquipmentDataService.selectViewEquipmentDataByEquipmentName(equipmentName));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:data:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViewEquipmentData viewEquipmentData)
    {
        return toAjax(viewEquipmentDataService.insertViewEquipmentData(viewEquipmentData));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:data:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViewEquipmentData viewEquipmentData)
    {
        return toAjax(viewEquipmentDataService.updateViewEquipmentData(viewEquipmentData));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:data:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentNames}")
    public AjaxResult remove(@PathVariable String[] equipmentNames)
    {
        return toAjax(viewEquipmentDataService.deleteViewEquipmentDataByEquipmentNames(equipmentNames));
    }
}
